﻿  cmake_minimum_required(VERSION 3.14)

#cmake_policy(SET CMP0074 OLD) 

  
 PROJECT(EPowerViewer) #项目

message(--------------------------------------------------------------------------------------------------------------) 

message( STATUS 项目 = ${PROJECT_NAME})


 set(CMAKE_CXX_STANDARD 17) 

 ADD_DEFINITIONS("-DUNICODE" "-D_UNICODE")
     

# 

message(--------------------------------------------------------------------------------------------------------------) 

 
message(--------------------------------------Power Viewer------------------------------------------------------) 


set(CMAKE_AUTOUIC ON)

set(CMAKE_AUTOMOC ON)

set(CMAKE_AUTORCC ON)

set(CMAKE_CXX_STANDARD 17)

set(CMAKE_CXX_STANDARD_REQUIRED ON)


 #if(MSVC)
     set(MY_VERSIONINFO_RC "${CMAKE_BINARY_DIR}/Version.rc")
     configure_file("${CMAKE_CURRENT_SOURCE_DIR}/Version.rc.in"
                 "${MY_VERSIONINFO_RC}")
 #endif()
  

AUX_SOURCE_DIRECTORY(.    SRC_FILES) 

FILE(GLOB HDR_FILES *.h )

FILE(GLOB UI_FILES *.ui)


FILE(GLOB QRC_SOURCE_FILES ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} ./Resources/*.qrc)

  ADD_EXECUTABLE(${PROJECT_NAME} WIN32
    ${SRC_FILES}
    ${HDR_FILES} 
    ${UI_FILES}
    
    ${QRC_SOURCE_FILES}

    resources/UI.qrc
    resources/skin.qrc

   # ${CMAKE_BINARY_DIR}/Version.rc
    )

TARGET_LINK_LIBRARIES(${PROJECT_NAME}   ws2_32 winmm  Qt5::Core Qt5::Widgets Qt5::Network Qt5::Xml Qt5::Svg Qt5::Multimedia )# snmpapi ws2_32 netapi32  kernel32 Wbemuuid ) 
 
INCLUDE_DIRECTORIES(${QT_INCLUDES})
 
INCLUDE_DIRECTORIES(${QT_MODULE_INCLUDE_BASE})
INCLUDE_DIRECTORIES(${QT_MODULE_INCLUDE_BASE})

INCLUDE_DIRECTORIES(.)

 IF (Qt5_FOUND)  
    INCLUDE_DIRECTORIES( ${Qt5_INCLUDE_DIRS}) 
ENDIF(Qt5_FOUND)  
INCLUDE_DIRECTORIES(${Qt5_INCLUDE_DIRS})

IF (Qt5Widgets_FOUND)
   INCLUDE_DIRECTORIES(${Qt5Widgets_INCLUDE_DIRS})
ENDIF(Qt5Widgets_FOUND)
INCLUDE_DIRECTORIES(${Qt5Widgets_INCLUDE_DIRS})

IF (Qt5Core_FOUND)
 INCLUDE_DIRECTORIES(${Qt5Core_INCLUDE_DIRS})
ENDIF(Qt5Core_FOUND)
INCLUDE_DIRECTORIES(${Qt5Core_INCLUDE_DIRS})

IF (Qt5Base_FOUND)
   INCLUDE_DIRECTORIES( ${Qt5Base_INCLUDE_DIRS})
ENDIF(Qt5Base_FOUND)
INCLUDE_DIRECTORIES(${Qt5Base_INCLUDE_DIRS})

#添加子目录 
  

IF(MSVC)
    SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "/MP")
     CONFIGURE_FILE("${PROJECT_SOURCE_DIR}/../../other/VSUserTemplate.vcxproj.user" "${PROJECT_BINARY_DIR}/${PROJECT_NAME}.vcxproj.user")
     ADD_DEFINITIONS(-D_WIN32_WINNT=0x0600 -D_CRT_SECURE_NO_WARNINGS)
     set_target_properties(  ${PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "$<TARGET_FILE_DIR:${PROJECT_NAME}>")
ENDIF(MSVC)


message(-------------------------------------------------------) 


INCLUDE_DIRECTORIES("../QCustomplot")
ADD_DEPENDENCIES(${PROJECT_NAME}   QCustomplot)
TARGET_LINK_LIBRARIES(${PROJECT_NAME}    QCustomplot) 

INCLUDE_DIRECTORIES("../Customplot")
ADD_DEPENDENCIES(${PROJECT_NAME}   Customplot)
TARGET_LINK_LIBRARIES(${PROJECT_NAME}    Customplot)

INCLUDE_DIRECTORIES("../Net")
ADD_DEPENDENCIES(${PROJECT_NAME}   Net)
TARGET_LINK_LIBRARIES(${PROJECT_NAME}    Net)

INCLUDE_DIRECTORIES("../qextserialport")
ADD_DEPENDENCIES(${PROJECT_NAME}   qextserialport)
TARGET_LINK_LIBRARIES(${PROJECT_NAME}    qextserialport)
